package com.tz.common.util;

import android.content.Context;


import com.google.gson.Gson;

import java.lang.reflect.Type;

/**
 * Json conversion util
 * Created by Chris on 16/7/19.
 */
public class JsonUtils {

    private static Gson mGson;

    public static void init(Context context) {
        mGson = new Gson();
    }

    public static String toJson(Object src) {
        return mGson.toJson(src);
    }

    public static <T> T fromJson(String json, Class<T> classOfT) {
        return mGson.fromJson(json, classOfT);
    }

    public static <T> T fromJson(String json, Type typeOfT) {
        return mGson.fromJson(json, typeOfT);
    }

}
